<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php include("db.php"); 	// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect
include_once("http://02d2e0a.netsolhost.com/includes/timeout.php");?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Kalamazoo Animal Rescue</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php include("http://02d2e0a.netsolhost.com/includes/head.inc");  ?>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<div id="bodywidth">
<?php include("http://02d2e0a.netsolhost.com/includes/header.inc");  ?>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<?php include("http://02d2e0a.netsolhost.com/includes/leftmenu.inc");
if (!isset($_SESSION['name']))
{ ?>
<div id="centercontent" style="width: 475px; height: auto">
<form method="GET" action="confirmlogin.php">
<table height="300px" width="100%" border=0 >
	<td align= center valign="top">
		<table height="300px" width="100%" border=0>
			<td align="center">
				<table width="100%" border=0>
				<td align="center">
				<font size=6>KAR Volunteer and Admin Login</font>
				</td>
			</td>
		</table>

		<br>

		<table width="400px" cellpadding="5%" border="0">
		<tr>
			<td align=right><font size=3><b>User Name:</b></font></td /align>
			<td><input type="text" name="user" size="20"></td>
		</tr>
		<tr>
			<td align=right><font size=3><b>Password:</b></td /align>
			<td><input type="password" name="password" size="20"></td>
		</tr>
		</table>

		<table width="100%" border="0">
		<tr>
			<td align=center><input type="submit" value="Login">
			
		</tr>
		</table>
	</td>
</table>
</div>
<? include("http://02d2e0a.netsolhost.com/includes/footer.inc");  ?>
</div>
</body>
</html>
<?php 
}
else
{ ?>
<div id="centercontent" style="width: auto; height: auto">
	<HR class="thickline"/>
<?php
// If no sorting method is selected, default to pet name
if(!isset($_GET['sortType']))
{
	$sortType="pet_name";
	$how="A";
}
else
{
	$sortType=$_GET['sortType'];
	$how=$_GET['how'];
}
//'A' MEANS SORT ASSENDING.. 'D' MEANS DESCENDING..
if($how == "A")
{
		{
		$query = "SELECT * FROM cats WHERE cats.pet_status=\"a\" ORDER BY " . $sortType . " ASC";
		$result = mysql_query($query);
		}
}
else
{
		$query = "SELECT * FROM cats WHERE cats.pet_status=\"a\" ORDER BY " . $sortType . " DESC";
		$result = mysql_query($query);
} ?>
<table width="100%" height=100% border=0>
	<tr height=100px>
		<td align=center valign=top>
			<table width="100%" height=75px border=0>
				<td align=center valign=top>
					<font size=6 face="Verdana Bold" >Pet Information</font><br>
					<p align=right><b>&nbsp;
					<a href="logout.php">Logout</a></p>
					<p align=center><a href="admin.php">Admin Home</a></p>
				</td>
			</table>
		</td>
	</tr>
	<tr>
		<td valign=top>
			<table width=100% height=100% border=0>
				<td width=501 align=center>
					<table width=500px border=1>
						<tr height=30px width=200px color="red">
						<?php
						//TABLE HEADERS AS LINKS SO WHEN THEY ARE CLICKED THE SORT ORDER WILL GET PASSED ALONG...
						if($sortType=="pet_name" && $how=="A")
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_name&how=D\"><font color=black>Name</font></a></th>";
						else
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_name&how=A\"><font color=black>Name</font></a></th>";
						if($sortType=="primaryBreed" && $how=="A")
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=primaryBreed&how=D\"><font color=black>Prim Breed</font></a></th>";
						else
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=primaryBreed&how=A\"><font color=black>Prim Breed</font></a></th>";
						if($sortType=="secondaryBreed" && $how=="A")
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=secondaryBreed&how=D\"><font color=black>Second Breed</font></a></th>";
						else
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=secondaryBreed&how=A\"><font color=black>Second Breed</font></a></th>";
						if($sortType=="pet_sex" && $how=="A")
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_sex&how=D\"><font color=black>Gender</font></a></th>";
						else
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_sex&how=A\"><font color=black>Gender</font></a></th>";
						if($sortType=="pet_DOB" && $how=="A")
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_DOB&how=D\"><font color=black>Age</font></a></th>";
						else
							echo "<th bgcolor=\"D3D3D3\"><a href=\"catintake.php?sortType=pet_DOB&how=A\"><font color=black>Age</font></a></th>";
						?>
						</tr>
						<?php
						// Enter while loop
						while($row=mysql_fetch_row($result))
						{
						$subColor="000000";
						$fontType="700";
						$breed = mysql_query("SELECT breedName FROM petfinderBreeds WHERE (animalType like '%Cat%' AND breedID = $row[4])");
						$primBreed = mysql_fetch_row($breed);
						$breed = mysql_query("SELECT breedName FROM petfinderBreeds WHERE (animalType like '%Cat%' AND breedID = $row[5])");
						$secBreed = mysql_fetch_row($breed);
						// Display Pet Info!
						echo "<tr height=25px width=500px>";
						echo "<td><a href=\"updatecat.php?petID=$row[0]\" style=\"text-decoration:none\"><font style=font-weight:$fontType color=$subColor>$row[2]</font></a></td>";
						echo "<td align=center><font style=font-weight:$fontType color=$subColor>$primBreed[0]</font></td>";
						echo "<td align=center><font style=font-weight:$fontType color=$subColor>$secBreed[0]</font></td>";
						echo "<td align=center><font style=font-weight:$fontType color=$subColor>$row[12]</font></td>";
						echo "<td align=center><font style=font-weight:$fontType color=$subColor>$row[13]</font></td>";
						echo "</tr>";
						} ?>
					</table>
				</td>
				</td>
			</table>
		</td>
	</tr>
</table>
</div>
<? include("http://02d2e0a.netsolhost.com/includes/footer.inc");  ?>
</div>
</body>
</html>
<? } ?>